tests: Make GSETTINGS_SCHEMA_DIR point to the compiled schemas in the build dir
authorChristoph Reiter <creiter@src.gnome.org>
Sat, 17 Feb 2018 08:48:12 +0000 (09:48 +0100)
committerChristoph Reiter <creiter@src.gnome.org>
Sat, 17 Feb 2018 08:48:12 +0000 (09:48 +0100)
With autotools the schemas were compiled into each test suite directory
and the tests set GSETTINGS_SCHEMA_DIR to the test build directory.

With meson's gnome.compile_schemas() we can not define a target directory
so just make sure it is built in the gtk directory and set GSETTINGS_SCHEMA_DIR
to the gtk build directory when running the tests.

This makes the gtk+:gtk suite pass when no gtk is installed on the system.

gtk/meson.build
testsuite/a11y/meson.build
testsuite/gtk/defaultvalue.c
testsuite/gtk/meson.build
testsuite/gtk/notify.c
testsuite/gtk/object.c
testsuite/gtk/objects-finalize.c
testsuite/gtk/templates.c
testsuite/reftests/gtk-reftest.c
testsuite/reftests/meson.build

index 92d4c0b43400ae211d85bbc22da5fde08e6a6013..8bea827edbb5b8cbacbc4c380e930ecf6bb604fc 100644 (file)
@@ -856,7 +856,9 @@ gtk_settings_schemas = [
   'org.gtk.Settings.Debug.gschema.xml',
 ]
 install_data(gtk_settings_schemas, install_dir: gtk_schemasdir)
-gnome.compile_schemas()
+gnome.compile_schemas(depend_files: files(gtk_settings_schemas),
+                      build_by_default: true)
+gtk_schema_build_dir = meson.current_build_dir()
 
 # Check for more things
 if cc.has_header('langinfo.h')
index 164eda40abfe2aeaca1a45289c53b6682237c791..4ae009a2cb5ee7ae1b955967b2a7de36fee4e07f 100644 (file)
@@ -27,7 +27,8 @@ foreach t: a11y_tests
                'GTK_CSD=1',
                'G_ENABLE_DIAGNOSTIC=0',
                'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
-               'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
+               'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+               'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir),
              ],
         suite: 'a11y')
 endforeach
index 1be85556c32ba06168d29a7572d57bddbe457f80..f011682fc43f49121ca524487b61464a47dbb5f1 100644 (file)
@@ -367,7 +367,6 @@ main (int argc, char **argv)
 {
   const GType *otypes;
   guint i;
-  gchar *schema_dir;
   GTestDBus *bus;
   GMainLoop *loop;
   gint result;
@@ -380,10 +379,6 @@ main (int argc, char **argv)
   gtk_test_init (&argc, &argv);
   gtk_test_register_all_types();
 
-  /* g_test_build_filename must be called after gtk_test_init */
-  schema_dir = g_test_build_filename (G_TEST_BUILT, "", NULL);
-  g_setenv ("GSETTINGS_SCHEMA_DIR", schema_dir, TRUE);
-
   /* Create one test bus for all tests, as we have a lot of very small
    * and quick tests.
    */
@@ -418,7 +413,6 @@ main (int argc, char **argv)
 
   g_test_dbus_down (bus);
   g_object_unref (bus);
-  g_free (schema_dir);
 
   return result;
 }
index c5b4ade9fa331c6291c7ea587061f6c1df1db01a..e8adb563367ecd00e4433bc4d90db34b4cbacde5 100644 (file)
@@ -80,7 +80,8 @@ foreach t : tests
               'G_ENABLE_DIAGNOSTIC=0',
               'GSK_RENDERER=cairo',
               'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
-              'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
+              'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+              'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir),
             ],
        suite: 'gtk')
 endforeach
@@ -100,7 +101,8 @@ if add_languages('cpp')
               'GTK_CSD=1',
               'G_ENABLE_DIAGNOSTIC=0',
               'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
-              'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
+              'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+              'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir),
             ],
        suite: 'gtk')
   if get_option('install-tests')
@@ -114,11 +116,6 @@ if add_languages('cpp')
   endif
 endif
 
-# FIXME: schemas from gtk+ dir?
-# $(top_srcdir)/gtk/org.gtk.Settings.ColorChooser.gschema.xml
-# $(top_srcdir)/gtk/org.gtk.Settings.FileChooser.gschema.xml
-# gnome.compile_schemas()
-
 if get_option('install-tests')
   foreach t : tests
     test_name = t.get(0)
index 0dfc8c73154b32ee6ed174b63df054fd4313db08..3f922a2cbe87b611d7857af98f42ac71a258568e 100644 (file)
@@ -657,16 +657,11 @@ main (int argc, char **argv)
 {
   const GType *otypes;
   guint i;
-  gchar *schema_dir;
   gint result;
 
   gtk_test_init (&argc, &argv);
   gtk_test_register_all_types();
 
-  /* g_test_build_filename must be called after gtk_test_init */
-  schema_dir = g_test_build_filename (G_TEST_BUILT, "", NULL);
-  g_setenv ("GSETTINGS_SCHEMA_DIR", schema_dir, TRUE);
-
   otypes = gtk_test_list_all_types (NULL);
   for (i = 0; otypes[i]; i++)
     {
@@ -679,7 +674,5 @@ main (int argc, char **argv)
 
   result = g_test_run ();
 
-  g_free (schema_dir);
-
   return result;
 }
index 2da75f5cea9f18525eba0a3c93026ff816345f9b..afbe9fda98414fc39bf05001d5d264d79bafc88c 100644 (file)
@@ -323,7 +323,6 @@ main (int   argc,
 {
   const GType *otypes;
   guint i;
-  gchar *schema_dir;
 
   g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
 
@@ -331,10 +330,6 @@ main (int   argc,
   gtk_test_init (&argc, &argv);
   gtk_test_register_all_types ();
 
-  /* g_test_build_filename must be called after gtk_test_init */
-  schema_dir = g_test_build_filename (G_TEST_BUILT, "", NULL);
-  g_setenv ("GSETTINGS_SCHEMA_DIR", schema_dir, TRUE);
-
   /* install a property test for each widget type */
   otypes = gtk_test_list_all_types (NULL);
   for (i = 0; otypes[i]; i++)
@@ -347,6 +342,5 @@ main (int   argc,
         g_free (testpath);
       }
 
-  g_free (schema_dir);
   return g_test_run ();
 }
index b7b358641dabec25ecb407ec5cb9df4bcb44b077..d08c42619c9c75a1b8ab145adfa4b86a1c60e662 100644 (file)
@@ -82,7 +82,6 @@ main (int argc, char **argv)
 {
   const GType *all_types;
   guint n_types = 0, i;
-  gchar *schema_dir;
   GTestDBus *bus;
   gint result;
 
@@ -94,10 +93,6 @@ main (int argc, char **argv)
   gtk_test_init (&argc, &argv);
   gtk_test_register_all_types ();
 
-  /* g_test_build_filename must be called after gtk_test_init */
-  schema_dir = g_test_build_filename (G_TEST_BUILT, "", NULL);
-  g_setenv ("GSETTINGS_SCHEMA_DIR", schema_dir, TRUE);
-
   /* Create one test bus for all tests, as we have a lot of very small
    * and quick tests.
    */
@@ -136,7 +131,6 @@ main (int argc, char **argv)
 
   g_test_dbus_down (bus);
   g_object_unref (bus);
-  g_free (schema_dir);
 
   return result;
 }
index affd0845a4ce321f7148e601a12ee9e573b3b413..712bf3e6aa7e18839d9f1e88c42b8a6a5ed41497 100644 (file)
@@ -328,8 +328,6 @@ test_print_unix_dialog_basic (void)
 int
 main (int argc, char **argv)
 {
-  gchar *schema_dir;
-
   /* These must be set before before gtk_test_init */
   g_setenv ("GIO_USE_VFS", "local", TRUE);
   g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
@@ -337,10 +335,6 @@ main (int argc, char **argv)
   /* initialize test program */
   gtk_test_init (&argc, &argv);
 
-  /* g_test_build_filename must be called after gtk_test_init */
-  schema_dir = g_test_build_filename (G_TEST_BUILT, "", NULL);
-  g_setenv ("GSETTINGS_SCHEMA_DIR", schema_dir, TRUE);
-
   /* This environment variable cooperates with gtk_widget_destroy()
    * to assert that all automated compoenents are properly finalized
    * when a given composite widget is destroyed.
@@ -374,7 +368,5 @@ main (int argc, char **argv)
   g_test_add_func ("/Template/UnixPrint/GtkPrintUnixDialog/Basic", test_print_unix_dialog_basic);
 #endif
 
-  g_free (schema_dir);
-
   return g_test_run();
 }
index 0179e0b3447f03f020d9faf0775fabc15b329867..3a4792e0310fb7acbd54c1d1040859794fbca96f 100644 (file)
@@ -62,7 +62,6 @@ parse_command_line (int *argc, char ***argv)
 {
   GError *error = NULL;
   GOptionContext *context;
-  char *schema_dir;
 
   context = g_option_context_new ("- run GTK reftests");
   g_option_context_add_main_entries (context, test_args, NULL);
@@ -76,11 +75,6 @@ parse_command_line (int *argc, char ***argv)
 
   gtk_test_init (argc, argv);
 
-  /* g_test_build_filename must be called after gtk_test_init */
-  schema_dir = g_test_build_filename (G_TEST_BUILT, "", NULL);
-  g_setenv ("GSETTINGS_SCHEMA_DIR", schema_dir, TRUE);
-  g_free (schema_dir);
-
   if (g_strcmp0 (arg_direction, "rtl") == 0)
     gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
   else if (g_strcmp0 (arg_direction, "ltr") == 0)
index 1604776bca69c29299dfe8e08b8ee7c0e7b8c4f6..479e10b3261a8cbe1f163d28408c0cdabf3f1560 100644 (file)
@@ -4,6 +4,7 @@ test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
 test_env.set('REFTEST_MODULE_DIR', meson.current_build_dir())
 test_env.set('GTK_IM_MODULE', 'gtk-im-context-simple')
 test_env.set('GSETTINGS_BACKEND', 'memory')
+test_env.set('GSETTINGS_SCHEMA_DIR', gtk_schema_build_dir)
 test_env.set('G_ENABLE_DIAGNOSTIC', '0')
 
 gtk_reftest_cargs = ['-DGDK_DISABLE_DEPRECATED', '-DGTK_DISABLE_DEPRECATED']
@@ -37,11 +38,6 @@ tcdata.set('libexecdir', join_paths(get_option('prefix'), get_option('libexecdir
 #    configuration : tcdata)
 #endforeach
 
-# FIXME: schemas from gtk+ dir?
-# $(top_srcdir)/gtk/org.gtk.Settings.ColorChooser.gschema.xml
-# $(top_srcdir)/gtk/org.gtk.Settings.FileChooser.gschema.xml
-# gnome.compile_schemas()
-
 gtk_reftest = executable('gtk-reftest', 'gtk-reftest.c',
   c_args : gtk_reftest_cargs,
   link_with : [libgtkreftestprivate, libreftest],